﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using Job.Core.Module;

namespace Job.Core
{

    public interface IBaseDAL<TKey, TType>
        where TType : Business<TKey, TType>, new()
        where TKey : IComparable
    {
        #region 基本属性方法
        /// <summary>
        /// 数据库连接名称
        /// </summary>
        string strConName { get; }
        /// <summary>
        /// 主键字段名称
        /// </summary>
        string strPrimaryKey { get; set; }
        /// <summary>
        /// 数据表名称
        /// </summary>
        string strTableName { get; set; }
        #endregion

        #region GetCount
        int GetCount(string strWhere);
        #endregion

        #region Exits
        bool Exists(int intID);
        bool Exists(string strWhere);
        #endregion

        #region Add
        int Add(DataTable dt);
        int Add(IDataReader dr);
        int Add(List<TType> list);
        int Add(TType model);
        #endregion Add

        #region Update
        int Update(DataTable dt);
        int Update(DataTable dt, string strColumnList);
        int Update(List<TType> list);
        int Update(List<TType> list, string strColumnList);
        bool Update(TType model);
        bool Update(TType model, string strColumnList);
        #endregion Update

        #region Delete
        int Delete(int intID);
        int Delete(string strWhere);
        int Delete(List<int> list);
        #endregion

        #region GetModel
        TType GetModel(int intID);
        TType GetModel(int intID, string strColumnList);
        TType GetModel(string strWhere);
        TType GetModel(string strWhere, string strColumnList);
        TType GetModel(string strWhere, string strColumnList, bool blOrderType);
        TType GetModel(string strWhere, string strColumnList, string strOrderColumn, bool blOrderType);
        TType GetModel(DataRow dr);
        TType GetModel(DataRowView drv);
        TType GetModel(IDataReader dr);
        #endregion GetModel

        #region  GetList
        List<TType> GetListByQuery(string strSql);

        List<TType> GetList();
        List<TType> GetList(string strWhere);
        List<TType> GetList(string strWhere, int intPageSize, int intPageIndex);
        List<TType> GetList(string strWhere, int intPageSize, int intPageIndex, string strColumnList);
        List<TType> GetList(string strWhere, int intPageSize, int intPageIndex, string strColumnList, bool blOrderType);
        List<TType> GetList(string strWhere, int intPageSize, int intPageIndex, bool blOrderType);
        List<TType> GetList(string strWhere, int intPageSize, int intPageIndex, bool blOrderType, string strOrderColumn);
        List<TType> GetList(string strWhere, int intPageSize, int intPageIndex, bool blOrderType, string strColumnList, string strOrderColumn);
        List<TType> GetList(DataTable dt);
        List<TType> GetList(IDataReader dr);
        List<TType> GetList(DataView dv);
        #endregion  GetList

        #region  GetResult
        List<TType> GetList(SearchQuery query);
        SearchResult<TType> GetResult(SearchQuery query);

        DataSet GetDataSet(SearchQuery query);
        DataTable GetDataTable(SearchQuery query);
        #endregion  GetList

        #region  GetDataTable
        DataTable GetDataTable(string strWhere);
        DataTable GetDataTable(string strWhere, int intPageSize, int intPageIndex);
        DataTable GetDataTable(string strWhere, int intPageSize, int intPageIndex, bool blOrderType);
        DataTable GetDataTable(string strWhere, int intPageSize, int intPageIndex, bool blOrderType, string strColumnList);
        DataTable GetDataTable(string strWhere, int intPageSize, int intPageIndex, bool blOrderType, string strColumnList, string strOrderColumn);
        #endregion GetDataTable

        #region  GetReader
        IDataReader GetReader(string strWhere);
        IDataReader GetReader(string strWhere, int intPageSize, int intPageIndex);
        IDataReader GetReader(string strWhere, int intPageSize, int intPageIndex, bool blOrderType);
        IDataReader GetReader(string strWhere, int intPageSize, int intPageIndex, bool blOrderType, string strColumnList);
        IDataReader GetReader(string strWhere, int intPageSize, int intPageIndex, bool blOrderType, string strColumnList, string strOrderColumn);
        #endregion GetReader
    }
}